import api from '@/utils/http'
import type { BaseResult, PageParams, PageResult } from '@/types/axios.d'
import type { CommodityClassType } from '@/api/model/commodityClassModel'

// 商品类别管理查询
export function getCommodityClassList(
  data: PageParams
): Promise<BaseResult<PageResult<CommodityClassType>>> {
  return api.post({
    url: '/classify/getAll',
    params: data
  })
}
export function getCommodityClassTree(
    data: PageParams
): Promise<BaseResult<CommodityClassType[]>> {
  return api.post({
    url: '/classify/tree',
    params: data
  })
}
// 添加商品类别
export function addCommodityClass(data: {
  classifyName: string
  classifyId?: number
  oneClassifyId?: number
  classifyImage?: string
}): Promise<BaseResult<null>> {
  return api.post({
    url: '/classify/save',
    data
  })
}

// 修改商品类别
export function updateCommodityClass(data: {
  classifyName: string
  classifyId: number
  oneClassifyId?: number
}): Promise<BaseResult<null>> {
  return api.post({
    url: '/classify/update',
    data
  })
}

export function updateCommodityClass1(data: {
  id?: number
  classifyName: string
  parentId?: number
  classifyImage: string
}): Promise<BaseResult<null>> {
  return api.post({
    url: '/classify/update1',
    data
  })
}

// 删除商品类别
export function deleteCommodityClass(data: { oneClassifyId: number }): Promise<BaseResult<null>> {
  return api.post({
    url: '/classify/delete',
    data
  })
}
export function deleteCommodityClass1(data: { oneClassifyId: number }): Promise<BaseResult<null>> {
  return api.post({
    url: '/classify/delete1',
    data
  })
}
// 商品类别编辑查询
export function getCommodityClassById(data: {
  oneClassifyId: number
}): Promise<BaseResult<CommodityClassType>> {
  return api.post({
    url: '/classify/getById',
    data
  })
}
